package leetcode;

public class LeetCodeMain102 {
    public int[] printNumbers(int n) {
        int sum=0;
        while (n!=0){
            n--;
            sum=sum*10+9;
        }
        int[] arr=new int[sum];
        for (int i = 0; i < sum; i++) {
            arr[i]=i+1;
        }
        return arr;
    }
    public int[] exchange(int[] nums) {
        int left=0;
        int right=nums.length-1;
        while (left<right){
            while (left<right&&nums[left]%2==1){
                left++;
            }
            while (left<right&&nums[right]%2==0){
                right--;
            }
            int tmp=nums[left];
            nums[left]=nums[right];
            nums[right]=tmp;
        }
        return nums;
    }
    public boolean isNumber(String s) {
        s=s.trim();
        if (s.contains(" ")){
            return false;
        }
        int num=s.length();
        if (num==0){
            return false;
        }
        if (num==1){
            if (Character.isDigit(s.charAt(0))){
                return true;
            }
            return false;
        }

        int index=0;
        if (s.lastIndexOf('+')==0){
            if (s.charAt(1)=='+'||s.charAt(1)=='-'){
                return false;
            }
            index=1;
        }
        if (s.lastIndexOf('-')==0){
            if (s.charAt(1)=='+'||s.charAt(1)=='-'){
                return false;
            }
            index=1;
        }
        String[] arr=null;
        s=s.substring(index,num);
        if (s.contains(" ")){
            return false;
        }
        if (s.contains("e")&&s.contains("E")){
            return false;
        }else if (s.contains("e")){
            arr=s.split("e");
        }else if (s.contains("E")){
            arr=s.split("E");
        }
        if (arr.length>2){
            return false;
        }else if (arr.length==2){
            if (arr[1].contains(".")){
                return false;
            }
            else if (arr[1].contains("+")&&arr[1].contains("-")){
                return false;
            }
            return true;
        }
        if (s.indexOf(".")!=s.lastIndexOf(".")){
            return false;
        }
        return true;
    }
    public ListNode getKthFromEnd(ListNode head, int k) {
        ListNode node=head;
        int count=0;
        while (node!=null){
            count++;
            node=node.next;
        }
        node=head;
        for (int i = 0; i < count-k; i++) {
            node=node.next;
        }
        head=node;
        return head;
    }
    public static void main(String[] args) {
        System.out.println(Integer.parseInt("+1.1"));

    }
}
